Skip to content

⚡️(frontend) improve accessibility of selected document's sub-menu #1261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Ovgodd
Copy link
Collaborator

@Ovgodd Ovgodd commented Aug 1, 2025

Purpose

This pull request improves the accessibility of the document tree by allowing keyboard users to:

  • See the action menu (e.g. “more options” and “create sub-document” buttons) when navigating with Tab.
  • Open a sub-document by pressing Enter when the corresponding tree item is focused.

issue : 1160

createsubdoc.mp4

Sub-document navigation is accessible, we can now navigate and open sub-docs using the keyboard.

Implementation note:
A small useTreeItemKeyboardActivate hook listens for Enter or Space only when the current node has focus (node.isFocused). This compensates for a limitation in react-arborist, which doesn't trigger any "activate" behavior on keyboard events.

For the action buttons (like ... or +) that appear when a tree item is focused:
By default, react-arborist uses a "roving tabindex", so these buttons are not reachable with Tab.
To fix this and make them keyboard-accessible:
I added a hook useActionableMode and some algo.

Proposal

  • Add :focus-within on the tree item wrapper to show the contextual action menu when a child receives focus.
  • Add :focus-visible outlines on buttons inside the menu to improve visible feedback.
  • Add aria-label attributes to make icon-only buttons screen reader accessible (e.g. “More options”, “Add chil document”).
  • Add keyboard support for the icon buttons using onKeyDown to handle Enter and Space.

@Ovgodd Ovgodd requested a review from AntoLC August 1, 2025 13:01
@Ovgodd Ovgodd self-assigned this Aug 1, 2025
@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch 2 times, most recently from 3463226 to a4249b3 Compare August 1, 2025 13:02
@Ovgodd Ovgodd marked this pull request as ready for review August 1, 2025 13:02
@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch 23 times, most recently from 6d0eba4 to 069359a Compare August 6, 2025 15:28
@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch 3 times, most recently from 0d49097 to fa6b764 Compare August 13, 2025 10:32
@Ovgodd
Copy link
Collaborator Author

Ovgodd commented Aug 13, 2025

I still don't see a test that show the keyboard interaction on the tree menu. #1261 (review)

Last thing, I can see that we have 2 components DropdownMenu, one coming from ui-kit, and another from src/components, they have different accessibility behaviors, could we unify this behavior ?

import {
DropdownMenu,
DropdownMenuOption,
useTreeContext,
} from '@gouvfr-lasuite/ui-kit';
import { useModal } from '@openfun/cunningham-react';

Indeed, I have removed the outline to match the kit behavior and style and add the missing auto focus for some element.

@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch 2 times, most recently from 927fffa to c515b80 Compare August 13, 2025 11:56
@Ovgodd Ovgodd requested a review from AntoLC August 13, 2025 12:00
@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch from c515b80 to d6ca4cd Compare August 13, 2025 13:07
@Ovgodd Ovgodd marked this pull request as draft August 13, 2025 14:11
@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch from d6ca4cd to 6b4c0e9 Compare August 13, 2025 15:47
@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch from 6b4c0e9 to 6eb9036 Compare August 13, 2025 16:12
@Ovgodd Ovgodd marked this pull request as ready for review August 13, 2025 16:12
@Ovgodd
Copy link
Collaborator Author

Ovgodd commented Aug 13, 2025

When there is a subdocs, I cannot unfold the doc with keyboard.

Enregistrement.de.l.ecran.2025-08-12.125242.mp4

subdocnavarrow.mp4

Fixed !

@Ovgodd Ovgodd force-pushed the fix/1160-sub-doc-access branch from f9da479 to 161ec74 Compare August 13, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants